package com.bubbles.workspace.sync.entity.source.enhance;

import com.bubbles.engine.data.core.entity.BaseEntity;
import com.bubbles.workspace.sync.entity.source.metadata.SourceColumn;
import com.bubbles.workspace.sync.key.source.enhance.SourceEnhanceDorisAnalyzeColumnKey;
import jakarta.persistence.*;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.annotations.Comment;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.util.Date;

/**
 * <p>description: 源数据源-增强--DORIS列分析记录 </p>
 *
 * @author CryptoNeedle
 * @date 2025-06-20
 */


@Data
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true, exclude = {"sourceColumn"})
@ToString(callSuper = true, exclude = {"sourceColumn"})
@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(schema = "sync", name = "source_enhance_doris_analyze_column")
@IdClass(SourceEnhanceDorisAnalyzeColumnKey.class)
@Comment("源数据源-增强--DORIS列分析记录")
public class SourceEnhanceDorisAnalyzeColumn extends BaseEntity {
    
    @Id
    @Comment("系统编码")
    private String sourceSystemCode;
    
    @Id
    @Comment("源数据源-数据库名称")
    private String sourceDatabaseName;
    
    @Id
    @Comment("源数据源-表名称")
    private String sourceTableName;
    
    @Id
    @Comment("源数据源-列名称")
    private String sourceColumnName;
    
    @Id
    @Comment("源数据源-统计时间")
    private Date sourceStatisticDatetime;
    
    @Comment("列所属的索引名")
    private String indexName;
    
    @Comment("列的行数")
    private Long count;
    
    @Comment("列的基数")
    private Long ndv;
    
    @Comment("列的空值数")
    private Long numNull;
    
    @Comment("列的总数据量")
    private Long dataSize;
    
    @Comment("列的平均字节数")
    private Double avgSizeByte;
    
    @Column(columnDefinition = "TEXT")
    @Comment("列的最小值")
    private String min;
    
    @Column(columnDefinition = "TEXT")
    @Comment("列的最大值")
    private String max;
    
    @Comment("收集方式")
    private String method;
    
    @Comment("收集类型")
    private String type;
    
    @Comment("触发方式")
    private String trigger;
    
    @Comment("信息被查询次数")
    private Integer queryTime;
    
    /**
     * 关联关系
     */
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumns({@JoinColumn(name = "sourceSystemCode", referencedColumnName = "sourceSystemCode", insertable = false, updatable = false), @JoinColumn(name = "sourceDatabaseName", referencedColumnName = "sourceDatabaseName", insertable = false, updatable = false), @JoinColumn(name = "sourceTableName", referencedColumnName = "sourceColumnName", insertable = false, updatable = false), @JoinColumn(name = "sourceColumnName", referencedColumnName = "sourceTableName", insertable = false, updatable = false)})
    private SourceColumn sourceColumn;
}